<?php

class Core_Model_Website_Template extends Dcmp_Model_Entity {

    public function __construct() {
        parent::__construct();
    }

    public function getModules($position) {
        $result = App::getModel('website/collection_block')
                        ->filterByTemplate($this->getId())
                        ->filterByPosition($position)
                        ->filterByEnabled(1)
                        ->field('b.name','module_name')->asc('sorting')
                        ->load();
        return $result;
    }

    protected function initializeTable($table) {
        $table->setName('{t}website_template');
        $table->createColumn('id', 'integer', TRUE, TRUE);
        $table->createColumn('name', 'string');
        $table->createColumn('theme', 'string');
        $table->createColumn('skin', 'string');
        $table->createColumn('area_id', 'integer');
        $table->createColumn('layout', 'string');
        $table->createColumn('position', 'string');
        $table->createColumn('creator_id', 'integer');
        $table->createColumn('created_time', 'datetime')->setDefaultValue(date('Y-m-d H:i:s'));
    }

}